<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            //Promise应用
            let p = new Promise((resolve) => {
                console.log('cb...');
                setTimeout(() => {
                    console.log('done');
                    resolve('1秒');
                }, 1000);
            })
                .then((res) => {
                    console.log('then() 1', res);
                })
                .then((res) => {
                    console.log('then() 2', res);
                    // return Promise.resolve('ok');
                })
                .then((res) => {
                    console.log('then() 3', res);
                })
                .then((res) => {
                    console.log('then() 4', res);
                });

            let p1 = new Promise((resolve) => {
                console.log('cb p1 ...');
                setTimeout(() => {
                    console.log('p1 done');
                    resolve('p1.. res ');
                }, 1000);
            }).then((res) => {
                console.log('then() p1', res);
            });
            // p.then((res) => {
            //     console.log('p.then() ', res);
            // });
            // setTimeout(() => {
            //     p.then((res) => {
            //         console.log('2000ms ', res);
            //     });
            // }, 2000);
            // setTimeout(() => {
            //     p.then((res) => {
            //         console.log('4000ms ', res);
            //     });
            // }, 4000);
        </script>
    </body>
</html>
